feat(GitClone): select an existing local checkout instead of cloning - #193
Conversation
<GitClone> now has a repository-source picker: clone from a remote (unchanged)
or point at a checkout the user already has on disk. Users often have the repo
already — a long-lived infrastructure-live checkout, a work in progress branch,
a monorepo they don't want to re-download.
Picking a directory inspects it without touching it: resolve the work tree root
via `git rev-parse --show-toplevel` (so any subdirectory of the checkout works),
read the origin remote and current branch, count tracked files. That runs as the
user types or browses, so a wrong directory says so immediately. Confirming with
"Use This Repo" registers the checkout as a session worktree and emits the same
outputs a clone does, so nothing downstream can tell the two apart: same
clone_path/repo_owner/repo_name, same $REPO_FILES, same workspace file tree,
same <GitPullRequest> flow (opening against the checkout's own remote and
current branch).
Backend:
- src/domain/git/local-repo.ts: inspectLocalRepo() — root resolution, remote/ref
metadata, tracked-file count, and typed user-facing failures for a missing
directory, a file, or a directory that isn't a git work tree. A repo with no
commits is still selectable.
- GitClient.getRepoRoot() added to the service, the CLI layer, and the test stub.
- git:local-repo IPC handler. The live preview passes register:false; only the
user confirming registers the worktree and resolves GitHub numeric IDs. That
split keeps a half-typed path from granting anything.
- workspace.ts: resolveValidatedWorktree() now accepts already-registered
worktrees. Without this, workspace:register / workspace:set-active silently
rejected any checkout outside the session working directory — which is where
local checkouts normally live — so the active-worktree selection didn't stick
and REPO_FILES could point at the wrong repo. It does not widen the grant:
an unregistered path outside the session still fails.
Frontend: SourceSelect (styled after GitAuth's ProviderSelect), LocalRepoForm
with a native folder picker, and source-aware copy in the result panel. New
props: source ('clone' | 'local'), hideSourceSelect, prefilledRepoDir — the last
one starts the block on the local source. Selecting a checkout requires no
credentials; only cloning still waits on a linked auth block. Instruction mode
renders `cd <path>` instead of a git clone command.
The runbook test framework adopts a checkout for source="local" rather than
cloning, counting tracked files instead of walking .git.
Tests: 11 domain tests for inspectLocalRepo, 12 component tests driving the real
hook against a mocked IPC boundary, 2 instruction-mode tests, and 2 CLI executor
tests against a real `git init` fixture. Docs cover the new source, props, and
output behaviour.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYour included review limit has been reached. You’re in a promotional period — use the checkbox below to run this review for free:
On-demand reviews are free for the next 30 days. After that, they cost $0.25 per reviewed file. How can I continue?Run this review now using the option above, or comment You can also wait for the limit to reset (next review available in 59 seconds), then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (23)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
<GitClone>gets a repository-source picker: Clone from remote (unchanged) or Use local checkout.Why
Users often already have the repo — a long-lived
infrastructure-livecheckout, a work in progress branch, a monorepo nobody wants to re-download. Today the only way into a runbook is a fresh clone.How it works
Picking a directory reads it only. The block resolves the work tree root with
git rev-parse --show-toplevel(so any subdirectory of the checkout works), reads theoriginremote and current branch, and counts tracked files. That runs as you type or browse, so a wrong directory says so immediately — nothing is fetched, pulled, or modified, and no credentials are needed.Confirming with Use This Repo registers the checkout as a session worktree and emits the same outputs a clone does, so nothing downstream can tell the two apart: same
clone_path/repo_owner/repo_name, same$REPO_FILES, same workspace file tree, same<GitPullRequest>flow — a PR opens against the checkout's own remote and current branch.New props:
source('clone' | 'local'),hideSourceSelect,prefilledRepoDir(setting it starts the block on the local source).Notable implementation points
git:local-repohas aregisterflag. The live preview passesregister: false; only the user confirming registers the worktree and resolves the GitHub numeric IDs. A half-typed path never grants anything.resolveValidatedWorktreenow accepts already-registered worktrees (electron/main/ipc/workspace.ts). Without this,workspace:register/workspace:set-activesilently rejected any checkout outside the session working directory — which is exactly where local checkouts live — so the active-worktree selection didn't stick andREPO_FILEScould point at the wrong repo. This does not widen the grant: an unregistered path outside the session still fails. The user's explicit selection is what grants access.originis still selectable, with an inline warning that PR blocks need a remote. A repo with no commits works too.cd <path>rather than agit clonecommand.source="local"instead of cloning, counting tracked files rather than walking.git.Testing
inspectLocalRepo— subdirectory → root resolution, relative vs absolute display paths, no remote, no commits, and each failure mode (missing dir, a file, not a work tree, empty input).useGitCloneagainst a mocked IPC boundary: source switching, prefill behaviour, the preview not registering, the confirm registering the worktree with the right owner/ref, the native folder picker, and the no-remote warning.git initfixture.992 backend + 604 web tests pass; typecheck, lint, and
just test-docsclean.Not verified in the desktop app — the UI is covered by component tests only, no live Electron run.
🤖 Generated with Claude Code